using System;
using System.Collections.Generic;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using AIFSCMSClient;

namespace UserOfAIFS
{
#if VS2005
    using UserOfAIFS2005.AIFSCMSService;
#else
    using AIFSCMSService;
#endif


    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            AIFSCMSServiceProvider provider = new AIFSCMSServiceProvider();
            provider.Timeout = 5000000;

            GetArticleListRequest request = new GetArticleListRequest();
            request.ArticleType = ArticleType.PROMO;
            request.ProgramName = "COLLEGE";
            request.FlaggedAsActive = true;

            FactExpressionBuilder builder = new FactExpressionBuilder();

            Criteria criteria = new Criteria();
            criteria.CriteriaExpressionArray = builder.CreateStringCriteria("COUNTRY").IsEqualTo("US")
                .AndNumericCriteria("POLICY_YEAR").IsEqualTo("2011").CriteriaExpression;

            Criteria orCountryCriteria = new Criteria();
            orCountryCriteria.CriteriaExpressionArray = builder.CreateStringCriteria("COUNTRY").IsEqualTo("TTT").CriteriaExpression;

            request.ArticleCriteria = criteria;
            request.OrArticleCriteriaList = new Criteria[] { orCountryCriteria};

            GetArticleListResponse result = (GetArticleListResponse)provider.GetArticleList(request);
            if (result.HasError)
            {
                Response.Write(String.Join(".", result.ErrorMessage));
                return;
            }

            if (result.HasDataInReturn)
            {
                rptrPromo.DataSource = result.ArticleList[0].Fragments;
                rptrPromo.DataBind();
            }
        }
    }
}
